home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / ECLASS.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-29  |  625b  |  23 lines

  1. PROCEDURE eclass(VAR nf: glnarray; n: integer;
  2.        lista,listb: glmarray; m: integer);
  3. (* Programs using routine ECLASS must define the types
  4. TYPE
  5.    glnarray = ARRAY [1..n] OF integer;
  6.    glmarray = ARRAY [1..m] OF integer;
  7. in the main routine. *)
  8. VAR
  9.    l,k,j: integer;
  10. BEGIN
  11.    FOR k := 1 TO n DO BEGIN
  12.       nf[k] := k
  13.    END;
  14.    FOR l := 1 TO m DO BEGIN
  15.       j := lista[l];
  16.       WHILE (nf[j] <> j) DO j := nf[j];
  17.       k := listb[l];
  18.       WHILE (nf[k] <> k) DO k := nf[k];
  19.       IF (j <> k) THEN nf[j] := k
  20.    END;
  21.    FOR j := 1 TO n DO WHILE (nf[j] <> nf[nf[j]]) DO nf[j] := nf[nf[j]];
  22. END;
  23.